package com.cennavi.minenavidemo.utils;

import com.minedata.minenavi.navi.ArrowInfo;
import com.minedata.minenavi.navi.MineNaviProgress;
import com.minedata.minenavi.navi.NaviSessionData;
import com.minedata.minenavi.navi.RouteBase;
import com.minedata.minenavi.navi.RouteCollection;
import com.minedata.minenavi.navi.RouterErrorInfo;
import com.minedata.minenavi.navi.SmoothNaviData;

import java.util.ArrayList;

public class MineNaviProgressManager extends MineNaviProgress {

    public interface OnMineNaviProgressListener {

        void onCalculateRouteSuccess(RouteCollection data);

        void onCalculateRouteFailed(RouterErrorInfo data);

        void onArriveDestination();

        void onNewArrow(ArrowInfo arrowInfo);

        void onDeleteArrow();

        void onRerouteComplete(RouteBase data);

        void onRerouteFailed(RouterErrorInfo data);

        void onNaviBegin();

        void onSimNaviBegin();

        void onSimNaviEnd();

        void onTracking(NaviSessionData data);

        void onSmoothTracking(SmoothNaviData data);
    }

    private ArrayList<OnMineNaviProgressListener> mOnMineNaviProgressListeners = new ArrayList<>();

    public void addOnNaviPresenterListener(OnMineNaviProgressListener listener) {
        mOnMineNaviProgressListeners.add(listener);
    }

    @Override
    public void onCalculateRouteSuccess(RouteCollection data) {
        super.onCalculateRouteSuccess(data);

        for (OnMineNaviProgressListener onMineNaviProgressListener : mOnMineNaviProgressListeners) {
            onMineNaviProgressListener.onCalculateRouteSuccess(data);
        }
    }

    @Override
    public void onCalculateRouteFailed(RouterErrorInfo data) {
        super.onCalculateRouteFailed(data);

        for (OnMineNaviProgressListener onMineNaviProgressListener : mOnMineNaviProgressListeners) {
            onMineNaviProgressListener.onCalculateRouteFailed(data);
        }
    }

    @Override
    public void onArriveDestination() {
        super.onArriveDestination();

        for (OnMineNaviProgressListener onMineNaviProgressListener : mOnMineNaviProgressListeners) {
            onMineNaviProgressListener.onArriveDestination();
        }
    }

    @Override
    public void onNewArrow(ArrowInfo arrowInfo) {
        super.onNewArrow(arrowInfo);

        for (OnMineNaviProgressListener onMineNaviProgressListener : mOnMineNaviProgressListeners) {
            onMineNaviProgressListener.onNewArrow(arrowInfo);
        }
    }

    @Override
    public void onDeleteArrow() {
        super.onDeleteArrow();

        for (OnMineNaviProgressListener onMineNaviProgressListener : mOnMineNaviProgressListeners) {
            onMineNaviProgressListener.onDeleteArrow();
        }
    }

    @Override
    public void onRerouteComplete(RouteBase data) {
        super.onRerouteComplete(data);

        for (OnMineNaviProgressListener onMineNaviProgressListener : mOnMineNaviProgressListeners) {
            onMineNaviProgressListener.onRerouteComplete(data);
        }
    }

    @Override
    public void onRerouteFailed(RouterErrorInfo data) {
        super.onRerouteFailed(data);

        for (OnMineNaviProgressListener onMineNaviProgressListener : mOnMineNaviProgressListeners) {
            onMineNaviProgressListener.onRerouteFailed(data);
        }
    }

    @Override
    public void onNaviBegin() {
        super.onNaviBegin();

        for (OnMineNaviProgressListener onMineNaviProgressListener : mOnMineNaviProgressListeners) {
            onMineNaviProgressListener.onNaviBegin();
        }
    }

    @Override
    public void onSimNaviBegin() {
        super.onSimNaviBegin();

        for (OnMineNaviProgressListener onMineNaviProgressListener : mOnMineNaviProgressListeners) {
            onMineNaviProgressListener.onSimNaviBegin();
        }
    }

    @Override
    public void onSimNaviEnd() {
        super.onSimNaviEnd();

        for (OnMineNaviProgressListener onMineNaviProgressListener : mOnMineNaviProgressListeners) {
            onMineNaviProgressListener.onSimNaviEnd();
        }
    }

    @Override
    public void onTracking(NaviSessionData data) {
        super.onTracking(data);

        for (OnMineNaviProgressListener onMineNaviProgressListener : mOnMineNaviProgressListeners) {
            onMineNaviProgressListener.onTracking(data);
        }
    }

    @Override
    public void onSmoothTracking(SmoothNaviData data) {
        super.onSmoothTracking(data);

        for (OnMineNaviProgressListener onMineNaviProgressListener : mOnMineNaviProgressListeners) {
            onMineNaviProgressListener.onSmoothTracking(data);
        }
    }
}
